<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台文章管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="/Public/Admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
    <link href="/Public/Admin/css/style.min862f.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/laypage/skin/laypage.css" rel="stylesheet">
    <link href="/Public/Admin/js/plugins/layer/skin/layer.css" rel="stylesheet">
    <style type="text/css">
        .table-bordered img{
            width: 60px;
            height: 60px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>文章管理</h5>
                <div class="ibox-tools">
                </div>
            </div>
            <div class="ibox-content">
                <div class="row m-b-sm m-t-sm">
                    <div class="col-md-2">
                        <a href="<?php echo U('article/add');?>" class="btn btn-outline btn-primary"><i class="fa fa-user-plus"></i>添加文章</a>
                    </div>
                    <form name="admin_list" id="admin_list" action="<?php echo U('article/index');?>" method="get">
                        <div class="col-md-3" style="margin-top: 2px">
                            <div class="input-group">
                                <input type="text" name="title" placeholder="请输入文章关键字" value="<?php echo ($title); ?>" class="input-sm form-control"> <span class="input-group-btn">
                                <button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
                            </div>
                        </div>
                    </form>
                </div>

                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>排序</th>
                        <th>所属栏目</th>
                        <th>文章标题</th>
                        <th>作者</th>
                        <th>添加人</th>
                        <th>发布时间</th>
                        <th>点击次数</th>
                        <th>文章内容</th>
                        <th>缩略图</th>
                        <th>关键词</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php if(is_array($list)): foreach($list as $key=>$va): ?><tr>
                            <td><?php echo ($va["id"]); ?></td>
                            <td><?php echo ($va["sort"]); ?></td>
                            <td><?php echo ($va["cat_id"]); ?></td>
                            <td><?php echo ($va["title"]); ?></td>
                            <td><?php echo ($va["author"]); ?></td>
                            <td><?php echo ($va["name"]); ?></td>
                            <td><?php echo (date("y-m-d",$va["addtime"])); ?></td>
                            <td><?php echo ($va["hits"]); ?></td>
                            <td><?php echo (mb_substr(htmlspecialchars_decode($va["content"]),0,100,utf8)); ?></td>
                            <td><img src="<?php echo ($va["litpic"]); ?>"></td>
                            <td><?php echo ($va["tag"]); ?></td>
                            <td>
                                <?php if(($va["status"] == 1)): ?><a href="javascript:changeState(<?php echo ($va["id"]); ?>)" id="state<?php echo ($va["id"]); ?>" class="btn-sm btn-primary btn-rounded">正常</a>
                                    <?php else: ?>
                                    <a href="javascript:changeState(<?php echo ($va["id"]); ?>)" id="state<?php echo ($va["id"]); ?>" class="btn-sm btn-danger btn-rounded">禁用</a><?php endif; ?>
                            </td>
                            <td >
                                <a href="<?php echo U('article/edit?id='.$va['id']);?>" type="button" class="btn-sm btn-primary btn-rounded"><i class="fa fa-edit"></i>修改</a>
                                <a href="javascript:delData(<?php echo ($va["id"]); ?>)" type="button" class="btn-sm btn-danger btn-rounded"><i class="fa fa-trash"></i>删除</a>
                            </td>
                        </tr><?php endforeach; endif; ?>
                    </tbody>
                </table>
                <div id="page1" style="text-align: center;"></div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="/Public/Admin/js/jquery.min.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/layer.min.js"></script>
<script src="/Public/Admin/js/plugins/layer/laypage/laypage.js"></script>
<script src="/Public/Admin/js/plugins/layer/laypage/laypage.js"></script>
<script src="/Public/Admin/js/common.js"></script>
<script>
var title = '<?php echo ($title); ?>';
    laypage({
        cont: 'page1', //容器。值可以传入元素id或原生DOM或jquery对象
        pages: <?php echo ($pages); ?>, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
        skin:'#OOFFFF', //当然，您还可以借助自定义皮肤
        skip:true, //是否显示跳转  类型：boolean  默认值：false()  开启是true(1)
        curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取 //curr 当前页
            var page = location.search.match(/page=(\d+)/);
            return page ? page[1] : 1;
        }(),
        jump: function(e, first){ //触发分页后的回调
            // 用于控制首页。值支持三种类型。 如：first: '首页' 如：first: false，则表示不显示首页项
            if(!first){ //一定要加此判断，否则初始时会无限刷新
                location.href = '?title='+ title +'&page='+e.curr;

            }
        }
    });
    //点击时修改状态
    function changeState(id){
        var objectState = $('#state' + id);
        common.status("<?php echo U('article/changeState');?>",id,objectState);
    }

    function delData(id){
        common.del("<?php echo U('article/del');?>",id,"<?php echo U('article/index');?>");
    }
</script>
</html>